package com.cx.factory;

public interface IAbstractFactory {
    /**
     * 创建Triangle对象
     * @return
     */
    Shape createTriangleBean();
    Shape createSquareBean();
}

 class AbstractFactory implements IAbstractFactory{
    @Override
    public Shape createTriangleBean() {
        return new Triangle();
    }
    @Override
    public Shape createSquareBean() {
        return new Square();
    }

     public static void main(String[] args) {
         IAbstractFactory beanFactory = new AbstractFactory();
         //创建Triangle对象
         Shape triangle = beanFactory.createTriangleBean();
         triangle.draw();
         //创建Square对象
         Shape square = beanFactory.createSquareBean();
         square.draw();
     }
}